#ifndef ssd1963_CMD_H
  #define ssd1963_CMD_H

// SSD1963 command table
#define CMD_NOP					0x00	//No operation
#define CMD_SOFT_RESET			0x01	//Software reset
#define CMD_GET_PWR_MODE		0x0A	//Get the current power mode
#define CMD_GET_ADDR_MODE		0x0B	//Get the frame memory to the display panel read order
#define CMD_GET_PIXEL_FORMAT	0x0C	//Get the current pixel format
#define CMD_GET_DISPLAY_MODE	0x0D	//Returns the display mode
#define CMD_GET_SIGNAL_MODE		0x0E	//
#define CMD_GET_DIAGNOSTIC		0x0F
#define CMD_ENT_SLEEP			0x10
#define CMD_EXIT_SLEEP			0x11
#define CMD_ENT_PARTIAL_MODE	0x12
#define CMD_ENT_NORMAL_MODE		0x13
#define CMD_EXIT_INVERT_MODE	0x20
#define CMD_ENT_INVERT_MODE		0x21
#define CMD_SET_GAMMA			0x26
#define CMD_BLANK_DISPLAY		0x28
#define CMD_ON_DISPLAY			0x29
#define CMD_SET_COLUMN			0x2A
#define CMD_SET_PAGE			0x2B
#define CMD_WR_MEMSTART			0x2C
#define CMD_RD_MEMSTART			0x2E
#define CMD_SET_PARTIAL_AREA	0x30
#define CMD_SET_SCROLL_AREA		0x33
#define CMD_SET_TEAR_OFF		0x34	//synchronization information is not sent from the display
#define CMD_SET_TEAR_ON			0x35	//sync. information is sent from the display
#define CMD_SET_ADDR_MODE		0x36	//set fram buffer read order to the display panel
#define CMD_SET_SCROLL_START	0x37
#define CMD_EXIT_IDLE_MODE		0x38
#define CMD_ENT_IDLE_MODE		0x39
#define CMD_SET_PIXEL_FORMAT	0x3A	//defines how many bits per pixel is used
#define CMD_WR_MEM_AUTO			0x3C
#define CMD_RD_MEM_AUTO			0x3E
#define CMD_SET_TEAR_SCANLINE	0x44
#define CMD_GET_SCANLINE		0x45
#define CMD_RD_DDB_START		0xA1
#define CMD_RD_DDB_AUTO			0xA8
#define CMD_SET_PANEL_MODE		0xB0
#define CMD_GET_PANEL_MODE		0xB1
#define CMD_SET_HOR_PERIOD		0xB4
#define CMD_GET_HOR_PERIOD		0xB5
#define CMD_SET_VER_PERIOD		0xB6
#define CMD_GET_VER_PERIOD		0xB7
#define CMD_SET_GPIO_CONF		0xB8
#define CMD_GET_GPIO_CONF		0xB9
#define CMD_SET_GPIO_VAL		0xBA
#define CMD_GET_GPIO_STATUS		0xBB
#define CMD_SET_POST_PROC		0xBC
#define CMD_GET_POST_PROC		0xBD
#define CMD_SET_PWM_CONF		0xBE
#define CMD_GET_PWM_CONF		0xBF
#define CMD_SET_LCD_GEN0		0xC0
#define CMD_GET_LCD_GEN0		0xC1
#define CMD_SET_LCD_GEN1		0xC2
#define CMD_GET_LCD_GEN1		0xC3
#define CMD_SET_LCD_GEN2		0xC4
#define CMD_GET_LCD_GEN2		0xC5
#define CMD_SET_LCD_GEN3		0xC6
#define CMD_GET_LCD_GEN3		0xC7
#define CMD_SET_GPIO0_ROP		0xC8
#define CMD_GET_GPIO0_ROP		0xC9
#define CMD_SET_GPIO1_ROP		0xCA
#define CMD_GET_GPIO1_ROP		0xCB
#define CMD_SET_GPIO2_ROP		0xCC
#define CMD_GET_GPIO2_ROP		0xCD
#define CMD_SET_GPIO3_ROP		0xCE
#define CMD_GET_GPIO3_ROP		0xCF
#define CMD_SET_ABC_DBC_CONF	0xD0
#define CMD_GET_ABC_DBC_CONF	0xD1
#define CMD_SET_DBC_HISTO_PTR	0xD2
#define CMD_GET_DBC_HISTO_PTR	0xD3
#define CMD_SET_DBC_THRES		0xD4
#define CMD_GET_DBC_THRES		0xD5
#define CMD_SET_ABM_TMR			0xD6
#define CMD_GET_ABM_TMR			0xD7
#define CMD_SET_AMB_LVL0		0xD8
#define CMD_GET_AMB_LVL0		0xD9
#define CMD_SET_AMB_LVL1		0xDA
#define CMD_GET_AMB_LVL1		0xDB
#define CMD_SET_AMB_LVL2		0xDC
#define CMD_GET_AMB_LVL2		0xDD
#define CMD_SET_AMB_LVL3		0xDE
#define CMD_GET_AMB_LVL3		0xDF
#define CMD_PLL_START			0xE0	//start the PLL
#define CMD_PLL_STOP			0xE1	//disable the PLL
#define CMD_SET_PLL_MN			0xE2
#define CMD_GET_PLL_MN			0xE3
#define CMD_GET_PLL_STATUS		0xE4	//get the current PLL status
#define CMD_ENT_DEEP_SLEEP		0xE5
#define CMD_SET_PCLK			0xE6	//set pixel clock (LSHIFT signal) frequency
#define CMD_GET_PCLK			0xE7	//get pixel clock (LSHIFT signal) freq. settings
#define CMD_SET_PIXEL_DATA_INTERFACE	0xF0
#define CMD_GET_PIXEL_DATA_INTERFACE	0xF1

/*********************************************************************
* Overview: Some basic colors definitions. 16 bits
*********************************************************************/
#define RGB565CONVERT(red, green, blue) (u16) (((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3))

#define BLACK               RGB565CONVERT(0,    0,      0)
#define BRIGHTBLUE          RGB565CONVERT(0,    0,      255)
#define BRIGHTGREEN         RGB565CONVERT(0,    255,    0)
#define BRIGHTCYAN          RGB565CONVERT(0,    255,    255)
#define BRIGHTRED           RGB565CONVERT(255,  0,      0)
#define BRIGHTMAGENTA       RGB565CONVERT(255,  0,      255)
#define BRIGHTYELLOW        RGB565CONVERT(255,  255,    0)
#define BLUE                RGB565CONVERT(0,    0,      128)
#define GREEN               RGB565CONVERT(0,    128,    0)
#define CYAN                RGB565CONVERT(0,    128,    128)
#define RED                 RGB565CONVERT(128,  0,      0)
#define MAGENTA             RGB565CONVERT(128,  0,      128)
#define BROWN               RGB565CONVERT(255,  128,    0)
#define LIGHTGRAY           RGB565CONVERT(128,  128,    128)
#define DARKGRAY            RGB565CONVERT(64,   64,     64)
#define LIGHTBLUE           RGB565CONVERT(128,  128,    255)
#define LIGHTGREEN          RGB565CONVERT(128,  255,    128)
#define LIGHTCYAN           RGB565CONVERT(128,  255,    255)
#define LIGHTRED            RGB565CONVERT(255,  128,    128)
#define LIGHTMAGENTA        RGB565CONVERT(255,  128,    255)
#define YELLOW              RGB565CONVERT(255,  255,    128)
#define WHITE               RGB565CONVERT(255,  255,    255)
                            
#define GRAY0       	    RGB565CONVERT(224,  224,    224)
#define GRAY1         	    RGB565CONVERT(192,  192,    192)   
#define GRAY2               RGB565CONVERT(160,  160,    160)   
#define GRAY3               RGB565CONVERT(128,  128,    128)
#define GRAY4               RGB565CONVERT(96,   96,     96)
#define GRAY5               RGB565CONVERT(64,   64,     64)
#define GRAY6	            RGB565CONVERT(32,   32,     32)


#define Set_Cs  GPIO_SetBits(GPIOF,GPIO_Pin_13);
#define Clr_Cs  GPIO_ResetBits(GPIOF,GPIO_Pin_13);

#define Set_Rs  GPIO_SetBits(GPIOF,GPIO_Pin_15);
#define Clr_Rs  GPIO_ResetBits(GPIOF,GPIO_Pin_15);

#define Set_nWr GPIO_SetBits(GPIOF,GPIO_Pin_11);
#define Clr_nWr GPIO_ResetBits(GPIOF,GPIO_Pin_11);

#define Set_nRd GPIO_SetBits(GPIOF,GPIO_Pin_12);
#define Clr_nRd GPIO_ResetBits(GPIOF,GPIO_Pin_12);

#define Set_Rst GPIO_SetBits(GPIOF,GPIO_Pin_14);
#define Clr_Rst GPIO_ResetBits(GPIOF,GPIO_Pin_14);



#endif
